package com.example.demo;
import static org.junit.jupiter.api.Assertions.assertEquals;


import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication



    /**
     * @Title: Triangle.java
     * @Package cn.edu.ctgu.junitTest
     * @Description: 测试三角形是否为等边、等腰或者是不等边三角形，或不是三角形
     * @author tiger
     * @version V1.0
     */
    public class Triangle {
        public String classify(int a, int b, int c) {
            if (a <1 || a>100 || b<1 || b>100 || c<1 || c> 100) {
                return "输入错误";
            }
            if (!((a + b > c) && (a + c > b) && (b + c > a))) {
                return "非三角形";
            } else if (a == b && a == c && b == c) {
                return "等边三角形";
            } else if (a != b && a != c && b != c) {
                return "不等边三角形";
            } else {
                return "等腰三角形";
            }
        }
    }

    class TriangleTest {
        @Test
        @DisplayName("输入错误")
        void parameters_error_test() {
            Triangle triangle = new Triangle();
            String type = triangle.classify(0, 4, 5);
            assertEquals("输入错误", type);
            System.out.println("Yes");
        }
        @Test
        @DisplayName("不等边三角形")
        void scalene_test1() {
            Triangle triangle = new Triangle();
            String type = triangle.classify(3, 4, 6);
            assertEquals("不等边三角形", type);
            System.out.println("Yes");
        }
        @Test
        @DisplayName("等边三角形")
        void scalene_test2() {
            Triangle triangle = new Triangle();
            String type = triangle.classify(3, 3, 3);
            assertEquals("等边三角形", type);
            System.out.println("Yes");
        }
        @Test
        @DisplayName("等腰三角形")
        void scalene_test3(){
            Triangle triangle = new Triangle();
            String type = triangle.classify(3, 3, 5);
            assertEquals("等腰三角形", type);
            System.out.println("Yes");
        }
        @Test
        @DisplayName("非三角形")
        void scalene_test4(){
            Triangle triangle = new Triangle();
            String type = triangle.classify(2, 2, 8);
            assertEquals("非三角形", type);
            System.out.println("Yes");
        }
    }


